<template>
  <div class="ratingPageContent">
    <div class="user-info">
      <div class="avatar"><img :src="rating.avatar" width="28" height="28" alt=""></div><div class="user">
        <div class="name">{{rating.username}} <span class="time">{{rating.rateTime | time}}</span> </div>
        <div class="star-wrapper"><star :size="24" :score="rating.score" ></star><span class="delivery">{{rating.deliveryTime}}分钟送达</span></div>
      </div>
    </div>
    <div class="rating-info">
      <p class="text">{{rating.text}}</p>
      <div class="recom-wrapper">
        <ul class="recom-list" >
          <li><span class="icon" :class="classMap[rating.rateType]"></span></li>
          <li class="recom"  v-for="item in rating.recommend">{{item}}</li>
        </ul>
      </div>
    </div>

  </div>
</template>

<script type="text/ecmascript-6">
  import star from '../star/star.vue'
  export default{
    props:{
      rating:{
        type:Object
      }
    },
    data() {
      return {
        classMap : [ 'icon-thumb_up', 'icon-thumb_down']

      }
    },
    filters:{
      time(value) {
        let date = new Date(value);
        let str= `${date.getFullYear()}-${date.getMonth()+1}-${date.getDate()}  ${date.getHours()}:${date.getMinutes()}`;
        return str;
      }
    },
    components:{
      star
    }

  }

</script>

<style rel="stylesheet/scss" lang="scss">
  @import "../../common/mixin";

  .ratingPageContent{
    padding: 18px 0;
    @include border-1px(rgba(7,17,27,0.1));
    .user-info{
      .avatar{
        display: inline-block;
        vertical-align: top;
        img{
          border-radius: 50%;
        }
      }
      .user{
        display: inline-block;
        margin-left: 12px ;
        font-size: 10px;
        line-height: 12px;
        color: rgb(7,17,27);
        vertical-align: top;
        .time{
          position: absolute;
          right: 0;
          top: 0;
          color: rgb(147,153,159);
        }
      }
      .star-wrapper{
        margin: 4px 0 6px;
        .delivery{
          font-size: 10px;
          font-weight: 200;
          line-height: 12px;
          color: rgb(147,153,159);
        }
      }
    }
    .rating-info{
      .text{
        margin-left: 40px;
        margin-bottom: 8px;
        font-size: 12px;
        line-height: 18px;
        color: rgb(7,17,27);
      }
      .recom-wrapper{
        margin-left: 40px;
        .recom-list{
          &>li{
            display: inline-block;
          }
          .recom{
            margin-left: 8px;
            font-size: 9px;
            color: rgb(147,163,159);
            line-height: 16px;
            border: 1px solid rgba(7,17,27,0.1);
            border-radius: 2px;
            padding: 2px;
          }
        }

      }
    }
  }

  .icon{
    font-size: 12px;
    line-height: 16px;
  }
  .icon-thumb_up{
    color: rgb(0,160,220);
  }
  .icon-thumb_down{
    color: rgb(147, 153, 169);
  }
</style>
